<script src="/static/admin/video/jquery.js"></script>
<script src="/static/file/webix/webix.js?v=7.1.1" type="text/javascript"></script>
<script src="/static/file/filemanager.js?v=7.1.1" type="text/javascript"></script>
<link rel="stylesheet" href="/static/admin/layui/layui-icon-extend/iconfont.css" media="all">
<link rel="stylesheet" type="text/css" href="/static/file/webix/webix.css?v=7.1.1">
<link rel="stylesheet" type="text/css" href="/static/file/filemanager.css?v=7.1.1">
<script src="/static/layuiadmin/layui/layui.js"></script>
<script type="text/javascript">
    var url = "{:url('file/index')}";
    webix.ready(function () {
        //存在BUG
        webix.i18n.setLocale("zh-CN");
        var fManager = new webix.ui({
            view: "filemanager",
            id: "files",
            css: "header",
            handlers: {
                "upload": "{:url('file/action')}",
                "download": "{:url('file/action')}",
                "copy": "{:url('file/action')}",
                "move": "{:url('file/action')}",
                "remove": "{:url('file/action')}",
                "rename": "{:url('file/action')}",
                "create": "{:url('file/action')}"
            },
            templateCreate: function () {
                return {value: "新建文件夹", type: "folder", date: new Date()};
            },
            icons: {
                folder: "folder",
                xlsx: "file-excel",
                pdf: "file-pdf",
                ppt: "file-powerpoint",
                txt: "file-text",
                MOV: "file-video",
                mp4: "file-video",
                AVI: "file-video",
                WMV: "file-video",
                jpg: "file-image",
                jpge: "file-image",
                PNG: "file-image",
                gif: "file-image",
                bmp: "file-image",
                html: "file-code",
                mp3: "file-audio",
                zip: "file-archive",
                docx: "file-word",
                file: "file"
            },
            templateIcon: function (fileObj, common) {

                return "<span style='float: none!important;' class='webix_icon webix_fmanager_icon fm-"
                    + (common.icons[fileObj.type] || common.icons["file"]) + "'></span>";
            },

        });
        //加载
        $.ajax({
            url: url,
            type: "post",
            typeData: "json",
            success: function (res) {
                $$("files").parse(res);
            }
        });
        $$("files").attachEvent("onBeforeRun", function (id) {
            webix.confirm({
                text: "您要下载本文件么?",
                ok: "下载",
                cancel: "取消",
                callback: function (result) {
                    if (result)
                        $$("files").download(id);
                }
            });
            return false;
        });
        //$$('files').disable(); //禁用视图
        $$("files").show();

    });
</script>